import service from "@/utils/request"

import LoginWork from "@/utils/LoginWork" 

// 通用材料查询
export interface GeneralMaterialsQueryPamrs{
    mtlName:string,
    mtlTypeL:string,
    mtlTypeS:string,
    pageNum:number,
    pageSize:number
}

export interface GeneralMaterialsQueryInterface{
    total?:number,
    dtos:dtosList[]
}

interface dtosList{
    mtlNo: string,
    mtlTypeNo: string,
    mtlTypeName: string,
    mtlName: string,
    mtlSpec: string,
    mtlColor: null | string,
    mtlUnit: string,
    stkQty: null | string
}

export const GeneralMaterialsQuery = (parms:GeneralMaterialsQueryPamrs) =>{ 
    return service.put<any,GeneralMaterialsQueryInterface>(`/pcFactorStockQuery/getLotComMtlQuery2`,parms)
}

// 通用材料查询 -> 材料大类子类
export interface MaterialCategoryInterface{
    typeNo: string,
    typeName: string
}

export const MaterialCategory = (mtlType?:string) =>{ 
    return service.get<any,MaterialCategoryInterface[]>(`/back/mtlTypeLMSQuery?mtlType=${mtlType}`)
}

// 指令资料 
export interface InstructionDataInterface{
    total?:number,
    dtos:dtosTableDateList[]
}

interface dtosTableDateList{
    lotNo: string,
    seqNo: number,
    partName: string,
    segment: number,
    mtlTypeNo: string,
    mtlType: string,
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    ttlUsage: number,
    stkQty: number
}

export interface InstructionDataPamrs{
    lotNo:string,
    mtlName:string,
    pageNum:number,
    pageSize:number,
    style:string,
    typeNo:string
}

export const InstructionDataList = (parms:InstructionDataPamrs) => {
    return service.put<any,InstructionDataInterface>('/pcFactorStockQuery/getLotMtlQuery2',parms)
}

// 指令资料 -> 材料分类
export const materialsClassification = () => {
    return service.post<any,MaterialCategoryInterface[]>(`/back/getMtlType`)
}

// 型体材料
export interface BulkMaterialInterface{
    total?: number,
    dtos: kl[]
}

interface kl{
    styleNo: null,
    styleColor: null,
    seqNo: number,
    partName: string,
    segment: number,
    mtlType: string,
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    stkQty: null
}

export interface BulkMaterialParms{
    mtlName:string,
    mtlTypeNo:string,
    pageNum:number,
    pageSize:number,
    styleColor:string,
    styleNo:string
}

export const BulkMaterial = (parms:BulkMaterialParms) => {
    return service.put<any,BulkMaterialInterface>('/pcFactorStockQuery/getStyMtlQuery2',parms)
}

// 材料库
export interface materialDepotParms{
    mtlColor:string,
    mtlName_1:string,
    mtlName_2:string,
    mtlName_3:string,
    mtlSpec:string,
    mtlTypeL:string,
    mtlTypeM:string,
    mtlTypeS:string,
    mtlUnit:string,
    pageNum:number,
    pageSize:number
}

export interface materialDepotInterface{
    total?:number,
    dtos:dtosListK[]
}

interface dtosListK{
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string
}

export const materialDepot = (parms:materialDepotParms) => {
    return service.put<any,materialDepotInterface>('/pcFactorStockQuery/getComMtlQuery2',parms)
}

// 待出库明细
export interface DetailsToBeReleasedInterface{
    lotNo: string,
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    qty: number,
    stkQty: number,
    remark: null,
    mtSpace:string,
    mtUnit:string
}

export const DetailsToBeReleased = () => {
    return service.post<any,DetailsToBeReleasedInterface[]>('/pcFactorStockQuery/getOtherMtlOutDtlQuery2')
}

// 其他材料出库明细
export interface OtherMaterialDeliveryDetailsParms{
    lotNo:string,
    mtlName:string,
    pageNum:number,
    pageSize:number,
    slipDateEnd:string,
    slipDateStart:string,
    slipNo:string,
    slipReason:string
}

export interface OtherMaterialDeliveryDetailsInterface{
    total?:number,
    dtos:dtosTableDateListKlc[]
}

interface dtosTableDateListKlc{
    slipNo: string,
    slipDate: string,
    slipReason: string,
    lotNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: string | null,
    mtlUnit: string,
    qty: number,
    remark: null,
    mtlNo: string,
    deptName: string,
    price: null,
    amt: null,
    sysUser: string
}

export const OtherMaterialDeliveryDetails = (parms:OtherMaterialDeliveryDetailsParms) => {
    return service.put<any,OtherMaterialDeliveryDetailsInterface>(`/pcFactorStockQuery/getOtherMtlOutQuery2`,parms)
}

// 出库原因
export const ReasonForDelivery = () => {
    return service.get<any,any>('/back/outSlipReasonQuery')
}

// 出库批处理
export interface AllDtos{
    code: number
    data: string 
    message: string
}

export interface BatchProcessingOutOfStorageParms{
    slipDate:string
    deptName:string
    deptNo:string
    slipReason:string
}


export const BatchProcessingOutOfStorage = (parms:BatchProcessingOutOfStorageParms[]) => {
    return LoginWork.put<any,AllDtos>('/pcFactorStockQuery/otherMtlOutStockAdd2',parms)
}

// 待入库新增
export const ToBeAddedInStorage = (type:number,parms:any) => {
    return LoginWork.put<any,AllDtos>(`/pcFactorStockQuery/otherMtlWaitStockAdd2?type=${type}`,parms)
}

// 贴合子材料明细查询
export const FitSubmaterialDetails = (mtlNo:any) => {
    return service.post<any,any>(`/pcFactorStockQuery/otherLotSubMtlQuery2?mtlNo=${mtlNo.mtlNo}`)
}

// 材料替代查询
export interface MaterialSubstitutionQueryParms{
    mtlName1:string,
    mtlName2:string,
    pageNum:number,
    pageSize:number,
    slipNo:string
}

export interface MaterialSubstitutionQueryInterface{
    total?: number,
    dtos: [ ]
}

interface dtosLi{
    outType: string,
    slipNo: string,
    mtlNo: string,
    mtlName: string,
    mtlColor: string,
    mtlSpec: string,
    mtlUnit: string,
    qty: number,
    mtlNo2: string,
    mtlName2: string,
    mtlColor2: string,
    mtlSpec2: string,
    mtlUnit2: string,
    qty2: number
}

export const  MaterialSubstitutionQuery = (parms:MaterialSubstitutionQueryParms) => {
    return service.put<any,MaterialSubstitutionQueryInterface>('/pcFactorStockQuery/getOtherMtlOutSubQuery2',parms)
}

// 整单删除
export const BlockDeletion = (slipNo:string) => {
    return LoginWork.post<any,AllDtos>(`/pcFactorStockQuery/otherMtlOutStockDelete2?slipNo=${slipNo}`)
}

// 材料替代
export interface MaterialSubstitutionMatercListParms{
    mtlColor:string,
    mtlName:string,
    mtlType:string,
    pageNum:number,
    pageSize:number,
}

export interface MaterialSubstitutionMatercListInterface{
    dtos:[],
    total?:number
}

export interface dto{
    mtlNo: string,
    mtlName: string,
    mtlUnit: string,
    mtlColor: string,
    stkQty: number
}


export const MaterialSubstitutionMatercList = (parms:MaterialSubstitutionMatercListParms) => {
    return service.put<any,MaterialSubstitutionMatercListInterface>('/back/getMtlSub',parms)
}

